//
//  ZKLineChartBgView.m
//  Private_Object
//
//  Created by pro on 16/10/6.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "ZKLineChartBgView.h"

@implementation ZKLineChartBgView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
- (void)setLines:(NSNumber *)lines {
    _lines = lines;
    
    [self setNeedsDisplay];
}

- (void)drawRect:(CGRect)rect {
    
    [super drawRect:rect];
    
    
    
    CGFloat x, y, width, height;
    for (int i = 0; i < _lines.integerValue; i ++) {
        width = rect.size.width;
        height = rect.size.height / _lines.integerValue - 0.5;
        x = 0;
        y = i * (height + 0.5);
        UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(x, y, width, height)];
        if (i % 2 == 0) {
            [[UIColor colorWithWhite:1 alpha:1] setFill];
        } else {
            [[UIColor colorWithWhite:0.96 alpha:1] setFill];
        }
        [path fill];
        
        [[UIColor clearColor] setStroke];
        [path stroke];
        
    }
}


@end
